package com.lhd._04mybatis.mapper;

import com.lhd._04mybatis.pojo.entity.Comment;
import com.lhd._04mybatis.vo.CommentVO1;
import com.lhd._04mybatis.vo.CommentVO2;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * @author lhd
 * @date 2024/4/18
 * @apiNote
 */
@Mapper
public interface CommentMapper {

    /**
     * 在评论表中插入1条数据
     * @param comment
     * @return
     */
//    @Insert("Insert Into comment(id,content,created,user_id,weibo_id) values (#{id},#{content},#{created},#{userId},#{weiboId})")
    int insertComment(Comment comment);

    /**
     * 根据微博记录id删除
     * @param cid
     * @return
     */
//    @Delete("DELETE from comment where id = #{cid}")
    int deleteComment(Long cid);

    /**
     * 根据评论id查询评论的内容 用户id 微博id
     * @param cid
     * @return
     */
//    @Select("SELECT content,user_id userId,weibo_id weiboId from comment where id = #{cid}")
    CommentVO1 selectCommentVO1ById(Long cid);

    /**
     * 根据微博的 id 查询评论的内容，用户ID
     * @param wid
     * @return
     */
//    @Select("SELECT content,user_id userId from comment where weibo_id = #{wid}")
    List<CommentVO2> selectCommentVO2ByWeiboId(Long wid);
}
